<template>
	<!-- 大客户项目报备管理  -审批明细-->
	<div class="wrapper mainAnchor">
		<!-- <Anchor class="mainAnchor" :labelList="labels" activeId="row-01" labelWidth="130"> -->
			<!-- <div class="line" style="min-height:700px" id="row-01"> -->
				<BreakSpace label="基本信息" :containerStyle="{ marginBottom: '10px' }" />
				<BasicInfo ref="basicFrom" :formType="infoType" v-model="formData" @formchange="basicFromChange"/>
			<!-- </div>
			<div class="line" style="min-height:510px" id="row-02"> -->
				<BreakSpace label="项目信息" :containerStyle="{ marginBottom: '10px' }" />
				<ProjectInfo ref="projectForm" :formType="infoType" v-model="formData" @formchange="projectFormChange"/>
			<!-- </div>
			<div class="line" style="min-height:310px" id="row-03"> -->
				<BreakSpace label="竞争对手分析" :containerStyle="{ marginBottom: '10px' }" />
				<OpponentInfo ref="opponentForm" :formType="infoType" v-model="formData" @formchange="opponentFormChange"/>
			<!-- </div>
			<div class="line" id="row-04"> -->
				<BreakSpace label="联系人信息" :containerStyle="{ marginBottom: '10px' }" />
				<ContactInfo ref="contactFrom" :formType="infoType" v-model="formData" @formchange="contactFromChange"/>
			<!-- </div>
			<div class="line" id="row-05"> -->
				<BreakSpace label="意向车型需求信息" :containerStyle="{ marginBottom: '10px' }" />
				<CarInfo ref="carForm" :formType="infoType" v-model="formData" @formchange="carFormChange"/>
			<!-- </div> -->
			<!-- <div class="line" id="row-06" v-if="isExamine">
				<IdeaInfo ref="ideaInfo" v-model="ideaInfoData"/>
			</div> -->
		<!-- </Anchor> -->
		<IdeaInfo ref="ideaInfo" v-model="ideaInfoData" @close="examineClose"/>
		<div class="dialogBottmView">
			<el-button @click="closeDialog">关 闭</el-button>
			<el-button @click="saveDialog(-1)" type="primary" v-if="isExamine">审批驳回</el-button>
			<el-button @click="saveDialog(1)" type="primary" v-if="isExamine">审批通过</el-button>
		</div>
	</div>
</template>

<script>
	//api和类型
	import { getDealerCompanyByCode } from '@/api/common/org/dealerCompany';
	import { getReview,saveReview } from '@/api/cms-api/customerManage/approvalManage';
	import * as apiType from '@/api/cms-api/customerManage/approvalManage/types';

	import { authority } from '@/utils/authMixin';
	import { dictionary } from '@/utils/dictMixin';
	import autoLoding from '@/utils/loding';//等待框

	import BasicInfo from './infoBase'; //基本信息
	import ProjectInfo from './infoProject'; //项目信息
	import OpponentInfo from './infoOpponent'; //竞争对手
	import ContactInfo from './infoContact'; //联系人信息
	import CarInfo from './infoCar'; //意向车型需求信息
	import IdeaInfo from './infoIdea'; //审核意见和附件

	export default {
		name: 'DealerCompany',
		mixins: [authority, dictionary, autoLoding],
		components: {
			BasicInfo,
			ProjectInfo,
			OpponentInfo,
			ContactInfo,
			CarInfo,
			IdeaInfo
		},
		props: {
			value: {
				type: Number,
				required: true
			},
			infoType: {
				type: String,
				required: true
			},
			isExamine: {
				type: Boolean,
				required: true
			},
			examineType: {
				type: Number,
				required: true
			},
		},
		data() {
			return {
				// labels: [
				// 	{ title: '基本信息', id: 'row-01' },
				// 	{ title: '项目信息', id: 'row-02' },
				// 	{ title: '竞争对手分析', id: 'row-03' },
				// 	{ title: '联系人信息', id: 'row-04' },
				// 	{ title: '意向车型需求信息', id: 'row-05' },
				// ],
				formData: {
					allForm: {
						majorProjectContactList:[],
						majorProjectModelList:[],
					},
					majorProjectContact:{
						list:[],
						total:0
					},
					majorProjectModel:{
						list:[],
						total:0
					}
				},
				ideaInfoData:{
					projectId: this.value,
					examineFormData:{},
					infoBasic:this.isExamine?'edit':'view',
					isOk:this.isOk,
					examineType:this.examineType
				}
			};
		},
		mounted(){
			this.loadingVm = this.openLoding('.cover-container');
			if(this.infoType != 'add'){
				this.init();
			}else{
				this.closeLoding(this.loadingVm);
			}
		},
		methods: {
			//初始化数据
			async init(){
				//按ID查询数据
				let id = this.value;
				await getReview(id,{}).then(res=>{
					if(res.resultCode === 200){
						this.formData.allForm = res.data;

						this.ideaInfoData.formData = this.formData;

						this.$refs.basicFrom.init();
						this.$refs.projectForm.init();
						this.$refs.opponentForm.init();
						this.$refs.contactFrom.init();
						this.$refs.carForm.init();

						this.$refs.ideaInfo.initFormData();

						this.closeLoding(this.loadingVm);
					}
				});
			},
			basicFromChange(data){},
			projectFormChange(data){},
			opponentFormChange(data){},
			contactFromChange(data){},
			carFormChange(data){
			},			//审核子页关闭事件
			examineClose(){
				this.$emit('close', 'refresh');
			},
			//保存
			saveDialog(type) {
				//调取idea子页组件的
				this.$refs.ideaInfo.saveDialog(type);
			},
			//取消操作
			closeDialog() {
				this.$emit('close', { visible: false });
			}
		}
	}
</script>

<style scoped>
	#row-04,#row-05{
		height: auto;
		min-height: 100%
	}
	/* .wrapper,.line{
		height: calc(100vh - (110px + 180px));
	} */
	.drawer-content{
		height: calc(100% - 160px);
	}
	.line{
		overflow-x:hidden;
		overflow-y:auto;
	}
</style>
